
import logging

class Log:

    def __init__(self, logName, logLevel, logFile):

        # 创建一个logger
        self.logger = logging.getLogger(logName)
        self.logger.setLevel(logLevel)

        # 创建一个handler，用于写入日志文件
        self.fileHandler = logging.FileHandler("D:/garbage/log/" + logFile)
        self.fileHandler.setLevel(logLevel)

        # 定义handler的输出格式
        self.formatter = logging.Formatter(
            '%(asctime)s | %(name)s | %(levelname)s | %(module)s | %(funcName)s | %(message)s')

        self.fileHandler.setFormatter(self.formatter)

        # 给logger添加handler
        self.logger.addHandler(self.fileHandler)

















